import axios from 'axios'
import { Indicator } from 'mint-ui'

const ajax = axios.create({
  baseURL: 'http://www.xiongmaoyouxuan.com'
})

ajax.interceptors.request.use((config) => {
  Indicator.open('Loading...')
  return config
})

ajax.interceptors.response.use((resp) => {
  Indicator.close()
  return resp
})

export const getHomeList = () => {
  return ajax.get('/api/tabs?sa=')
}

export const getHomeShop = (starts) => {
  return ajax.get(`/api/tab/1/feeds?start=${starts}&sort=0`)
}

export const getHomeBanner = () => {
  return ajax.get('/api/tab/1?start=0')
}
export const getProductList = (tabid, start = 0) => {
  return ajax.get(`/api/tab/${tabid}?start=${start}`)
}
export const getProductDetail = (id) => {
  return ajax.get(`/api/detail?id=${id}&normal=1&sa=`)
}
export const postLogin = (msg) => {
  return ajax.post('http://rap2api.taobao.org/app/mock/163707/login', msg)
}
